<!-- 首页 -->
<template>
	<view class="container">
		<view class="c-rich">
			<view class="rich-content">
				<mp-html :content="gameInfo.content" />
			</view>
			<view class="rich-btn">
				<view @click="toGameSignUP" v-if="gameInfo.show_status==1">
					<text>立即报名</text>
				</view>
				<view v-else>
					<text>暂停报名</text>
				</view>
			</view>
		</view>
		<view class="c-overlay">
			<StatusOverlay v-if="isOverlay" @click.native="isOverlay=false"></StatusOverlay>
		</view>
	</view>
</template>

<script>
	import StatusOverlay from "@/pages/components/StatusOverlay.vue"
	export default {
		name:"gameDivisionDetail",
		components:{
			StatusOverlay
		},
		data() {
			return {
				// 用户身份
				status:this.$store.state.status,
				// 比赛详情
				gameInfo:{},
				// 身份认证
				isOverlay:false
			}
		},
		onLoad(query) {
			uni.setNavigationBarTitle({
				title:query.name
			})
			this.getGameDivisionInfo(query.id)
		},
		onShow(){
			this.status = uni.getStorageSync("status")
		},
		onHide() {
			this.isOverlay = false
		},
		
		methods: {
			// 获取详情
			getGameDivisionInfo(id){
				this.$http.getGameDivisionInfo({id}).then(res=>{
					this.gameInfo = res
				})
			},
			// 跳转报名页面
			toGameSignUP(){
				let type = uni.getStorageSync("userInfo").identityData
				if(!type){
					this.getUserInfo()
				}
				if(!this.$store.state.token){
					this.toLogin()
				}else if(!this.status || this.status == 'user'){
					this.isOverlay = true
				}else if((this.status == 'teacher' || this.status == 'org') && !type ){
					uni.$u.toast("您的身份认证申请正在审核中...")
				}else{
					this.navigateTo("gameSignUp")
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.container{
		.c-rich{
			width: 100%;
			.rich-content{
				&>image{
					width: 100%;
				}
			}
			.rich-btn {
				width: 100%;
				height: 100rpx;
				padding: 20rpx 0;
				position: fixed;
				bottom: 0;
				left: 0;
				background-color: #fff;
			
				&>view {
					// width: 160rpx;
					// height: 60rpx;
					width: 100%;
					font-size: 38rpx;
					font-weight: bold;
					color: #4093ec;
					display: flex;
					justify-content: center;
					align-items: center;
				}
			}
		}
	}
</style>
